<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        p {
            text-align: center;
            font-size: 20px;

        }

        span {
            color: red;
        }
    </style>
</head>
<body>
<p id=""><span id="time">5</span>秒后跳转到首页...</p>
<script>
    let time = document.getElementById("time");
    let number = 5;

    function showTime() {
        number--;
        time.innerHTML = number;
        if (number <= 0) {
            location.href = "https://www.baidu.com";
        }
    }

    setInterval(showTime, 1000);

</script>

</body>
</html>